package iPod;

import java.io.*;

import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException;

public class PlayCountItem {
	// Temporary access variable
	protected byte item[] = new byte[4];
	protected long startPos = 0;
	
	protected int playCount = 0;
	protected int rating = 0;
    
    public void loadRecord(RandomAccessFile in) throws Exception
    {
    	// Mark the beginning of this block (so we can reset)
    	startPos = in.getFilePointer();
    	
    	// read the header
    	loadHeader(in); 
    	
    	// jump back to the beginning
    	in.seek(startPos);
    }
    
    public void loadHeader(RandomAccessFile in) throws Exception
    {      	    	
    	// read the number of playcounts
    	in.read(item);
    	playCount = DataUtils.littleEndianToInt(item);
    	
    	// read the size of this record
    	in.seek(startPos + 12);
    	in.read(item);
    	rating = DataUtils.littleEndianToInt(item);
    }

	public int getPlayCount() {
		return playCount;
	}

	public int getRating() {
		return rating;
	}       
}
